import XML from "./XML";
import { Node } from "./node";

/**
 * XML列表
 * @author clong 2020.12.11
 */
export default class XMLList{

    public rawList: Array<XML>;
    public Count: number;

    constructor( list:Array<XML> = null ) {
        this.rawList = list || [];
    }

    public Add($xml:XML):void{
        this.rawList = this.rawList || [];
        $xml && this.rawList.push($xml);
        this.Count = this.rawList && this.rawList.length;
    }
    public Clear():void{
        this.rawList = [];
        this.Count = 0;
    }
    public get_Item($index: number):XML{
        return this.rawList && this.rawList[$index];
    }
    public Find($selector: string):XML{
        return null;
    }

    public addNode( node:Node ):void{

        let xml:XML = new XML();
        xml.parseNode( node );
        this.Add(xml);
    }
}